package com.zdkj.subway.st.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.st.entity.SwStProduceLog;
import com.zdkj.subway.st.service.SwStProduceLogService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@AllArgsConstructor
@RequestMapping("/swStProducePlanLog")
@Api(value = "swStProducePlanLog", tags = "车票生产日志")
public class SwStProduceLogController {
	private final SwStProduceLogService swStProduceLogService;

	@GetMapping("/{id}")
	public R getById(@PathVariable String id) {
		return R.ok(swStProduceLogService.getById(id));
	}

	@GetMapping("/page")
	public R<IPage> getDictPage(Page page, SwStProduceLog swStProduceLog) {
		return R.ok(swStProduceLogService.page(page, Wrappers.query(swStProduceLog)));
	}

	@SysLog("车票生产日志")
	@PostMapping
	public R save(@Valid @RequestBody SwStProduceLog swStProduceLog) {
		return R.ok(swStProduceLogService.save(swStProduceLog));
	}

	@SysLog("删除车票生产日志")
	@DeleteMapping("/{id}")
	public R removeById(@PathVariable String id) {
		return R.ok(swStProduceLogService.removeById(id));
	}

	@PutMapping
	@SysLog("修改车票生产日志")
	public R updateById(@Valid @RequestBody SwStProduceLog swStProduceLog) {
		return R.ok(swStProduceLogService.updateById(swStProduceLog));
	}

}
